package com.taotao.manage.controller;

import java.lang.reflect.Method;
import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;




import com.taotao.manage.pojo.ItemDesc;
import com.taotao.manage.service.ItemDescService;

@RequestMapping("item/desc")
@Controller
public class ItemDescController {
	
	@Autowired
	private ItemDescService itemDescService;
	
	private static final Logger LOGGER = LoggerFactory.getLogger(ItemDescController.class);

	/**
	 * 查询商品描述
	 * @param page
	 * @param rows
	 * @return
	 */
	@RequestMapping(value="{id}",method=RequestMethod.GET)
	public ResponseEntity<ItemDesc> queryItemDesc(@PathVariable("id") long itemId) {
		try {
				if (LOGGER.isDebugEnabled()) {
					//{}为占位符
					LOGGER.debug("查询商品描述！ itemId={}",itemId);
					}
			ItemDesc itemDesc = itemDescService.queryById(itemId);
			  if(null == itemDesc){
	                return ResponseEntity.status(HttpStatus.NOT_FOUND).body(null);
	            }
			//成功响应200
			return ResponseEntity.status(HttpStatus.OK).body(itemDesc);	
		} catch (Exception e) {
			if (LOGGER.isDebugEnabled()) {
				//{}为占位符
				LOGGER.debug("查询商品描述失败！ itemId={}",itemId);
				}
			return ResponseEntity.status(HttpStatus.NOT_FOUND).body(null);
		}
	}
	
	
}
